<!--这是权限管理组件-->
<template>
<div class="app-container">
  <p>基本信息</p>
  <el-form :model="postForm" v-loading="formLoading" :rules="rules" ref="postForm" label-width="220px" label-position="right">
    <el-form-item label="账号：" prop="username">
      <el-input v-model="postForm.username" placeholder="请输入账号(至少6个字符)" class="width650"></el-input>
    </el-form-item>
    <el-form-item label="密码：" prop="password" v-if="showPwd">
      <el-input type="password" v-model="postForm.password" placeholder="请输入密码" class="width650"></el-input>
    </el-form-item>
    <el-form-item label="姓名：">
      <el-input v-model="postForm.name" placeholder="请输入姓名" class="width650"></el-input>
    </el-form-item>
    <el-form-item label="电话：">
      <el-input v-model="postForm.phone" placeholder="请输入电话" class="width650"></el-input>
    </el-form-item>
    <el-form-item label="状态：" required>
      <!-- <el-radio-group v-model="postForm.status"> -->
      <el-radio v-model="postForm.status" label="1">启用</el-radio>
      <el-radio v-model="postForm.status" label="-1">禁用</el-radio>
      <!-- </el-radio-group> -->
    </el-form-item>
    <el-form-item label="权限：" required>
      <el-collapse v-model="activeName" @change="handleChange" class="width650">
        <el-collapse-item name="1">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd1" v-model="postForm.all1" @change="handleCheckAllChange1($event)" class="margin-r10"></el-checkbox>店铺概况
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.dashboard" @change="dashboardFun">
            <el-checkbox v-for="item in dashboard" :label="item.key" :key="item.key" >{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="2">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd2" v-model="postForm.all2" @change="handleCheckAllChange2($event)" class="margin-r10"></el-checkbox>店铺管理
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.basicDatum" @change="basicDatumFun">
            <el-checkbox v-for="item in basicDatum" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.systemManage" @change="systemManageFun">
            <el-checkbox v-for="item in systemManage" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.courseCategory" @change="courseCategoryFun">
            <el-checkbox v-for="item in courseCategory" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.lecturers" @change="lecturersFun">
            <el-checkbox v-for="item in lecturers" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="10">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd10" v-model="postForm.all10" @change="handleCheckAllChange10($event)" class="margin-r10"></el-checkbox>用户管理
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.members" @change="membersFun">
            <el-checkbox v-for="item in members" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.vipBenefit" @change="vipBenefitFun">
            <el-checkbox v-for="item in vipBenefit" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="3">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd3" v-model="postForm.all3" @change="handleCheckAllChange3($event)" class="margin-r10"></el-checkbox>知识产品
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.videos" @change="videosFun">
            <el-checkbox v-for="item in videos" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.audios" @change="audiosFun">
            <el-checkbox v-for="item in audios" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.articles" @change="articlesFun">
            <el-checkbox v-for="item in articles" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.previews" @change="previewsFun">
            <el-checkbox v-for="item in previews" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group v-if="enableColumnModule" class="m-l-30" v-model="postForm.columns" @change="columnsFun">
            <el-checkbox v-for="item in columns" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group v-if="enableDatumModule" class="m-l-30" v-model="postForm.datums" @change="datumsFun">
            <el-checkbox v-for="item in datums" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group v-if="enableExamModule" class="m-l-30" v-model="postForm.test" @change="testFun">
            <el-checkbox v-for="item in test" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group v-if="enableResourceModule" class="m-l-30" v-model="postForm.resource" @change="resourceFun">
            <el-checkbox v-for="item in resource" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>

        <el-collapse-item name="4">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd4" v-model="postForm.all4" @change="handleCheckAllChange4($event)" class="margin-r10"></el-checkbox>互动产品
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group v-if="enableSocialGroup" class="m-l-30" v-model="postForm.social" @change="socialFun">
            <el-checkbox v-for="item in social" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group v-if="enableActivityModule" class="m-l-30" v-model="postForm.activities" @change="activitiesFun">
            <el-checkbox v-for="item in activities" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.comment" @change="commentFun">
            <el-checkbox v-for="item in comment" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="5" v-show="enableMallModule">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd5" v-model="postForm.all5" @change="handleCheckAllChange5($event)" class="margin-r10"></el-checkbox>商城管理
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.mallInfo" @change="mallInfoFun">
            <el-checkbox v-for="item in mallInfo" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.productList" @change="productListFun">
            <el-checkbox v-for="item in productList" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.orderList" @change="orderListFun">
            <el-checkbox v-for="item in orderList" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.mallSetting" @change="mallSettingFun">
            <el-checkbox v-for="item in mallSetting" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="6" v-if="isInd6">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd6" v-model="postForm.all6" @change="handleCheckAllChange6($event)" class="margin-r10"></el-checkbox>营销管理
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group v-if="enableAgentLevels" class="m-l-30" v-model="postForm.partner" @change="partnerFun">
            <el-checkbox v-for="item in partner" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group v-if="enablePoints" class="m-l-30" v-model="postForm.point" @change="pointFun">
            <el-checkbox v-for="item in point" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="7">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd7" v-model="postForm.all7" @change="handleCheckAllChange7($event)" class="margin-r10"></el-checkbox>订单管理
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.order" @change="orderFun">
            <el-checkbox v-for="item in order" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="8">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd8" v-model="postForm.all8" @change="handleCheckAllChange8($event)" class="margin-r10"></el-checkbox>财务管理
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.cashManage" @change="cashManageFun">
            <el-checkbox v-for="item in cashManage" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.companyIncome" @change="companyIncomeFun">
            <el-checkbox v-for="item in companyIncome" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.userIncome" @change="userIncomeFun">
            <el-checkbox v-for="item in userIncome" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
          <el-checkbox-group class="m-l-30" v-model="postForm.business" @change="businessFun">
            <el-checkbox v-for="item in business" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
        <el-collapse-item name="9" v-show="enableWxapp">
          <template slot="title">
              <el-checkbox :indeterminate="postForm.isInd9" v-model="postForm.all9" @change="handleCheckAllChange9($event)" class="margin-r10"></el-checkbox>小程序
            </template>
          <div class="c-mv15"></div>
          <el-checkbox-group class="m-l-30" v-model="postForm.wxapp" @change="wxappFun">
            <el-checkbox v-for="item in wxapp" :label="item.key" :key="item.key">{{item.value}}</el-checkbox>
          </el-checkbox-group>
        </el-collapse-item>
      </el-collapse>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" v-loading="btnLoading" icon="el-icon-check" @click="submitForm">保存</el-button>
    </el-form-item>
  </el-form>
</div>
</template>
<script>
import {
  savePermission,
  getPermissionDetail
} from '@/api/permission'
import {
  enableModules
} from '@/utils/permission'
// const cityOptions = ['店铺概况', '查看', '操作']
const dashboard = [{
  key: -1,
  value: '店铺概况'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const basicDatum = [{
  key: -1,
  value: '基础资料'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const systemManage = [{
  key: -1,
  value: '店铺装修'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const courseCategory = [{
  key: -1,
  value: '分类设置'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const lecturers = [{
  key: -1,
  value: '讲师管理'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const previews = [{
  key: -1,
  value: '预告'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const datums = [{
  key: -1,
  value: '资料'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const resource = [{
  key: -1,
  value: '资源'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const test = [{
  key: -1,
  value: '测评'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const videos = [{
  key: -1,
  value: '视频'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const audios = [{
  key: -1,
  value: '音频'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const articles = [{
  key: -1,
  value: '图文'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const columns = [{
  key: -1,
  value: '专栏'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const social = [{
  key: -1,
  value: '社群'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const activities = [{
  key: -1,
  value: '活动'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const comment = [{
  key: -1,
  value: '评论'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const mallSetting = [{
  key: -1,
  value: '商品配置'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const mallInfo = [{
  key: -1,
  value: '商城基础资料'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const productList = [{
  key: -1,
  value: '商品列表'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const orderList = [{
  key: -1,
  value: '订单列表'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const point = [{
  key: -1,
  value: '积分管理'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const partner = [{
  key: -1,
  value: '服务商管理'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const members = [{
  key: -1,
  value: '用户管理'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const vipBenefit = [{
  key: -1,
  value: '用户权益'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const order = [{
  key: -1,
  value: '订单管理'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const cashManage = [{
  key: -1,
  value: '提现管理'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const companyIncome = [{
  key: -1,
  value: '公司收入'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const userIncome = [{
  key: -1,
  value: '用户收入'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const business = [{
  key: -1,
  value: '营业情况'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const investMoneyList = [{
  key: -1,
  value: '用户充值列表'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const investMoney = [{
  key: -1,
  value: '充值管理'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]
const wxapp = [{
  key: -1,
  value: '小程序'
},
{
  key: 1,
  value: '查看'
},
{
  key: 2,
  value: '操作'
}
]

const rules = {
  username: [{
    required: true,
    message: '请输入账号',
    trigger: 'blur'
  }],
  password: [{
    required: true,
    message: '请输入密码',
    trigger: 'blur'
  }]
}
const postForm = {
  adminId: 0,
  username: '', // 账号
  password: '', // 密码
  name: '', // 姓名
  phone: '', // 号码
  status: '', // 状态
  all1: false,
  all2: false,
  all3: false,
  all4: false,
  all5: false,
  all6: false,
  all7: false,
  all8: false,
  all9: false,
  all10: false,
  isInd1: false,
  isInd2: false,
  isInd3: false,
  isInd4: false,
  isInd5: false,
  isInd6: false,
  isInd7: false,
  isInd8: false,
  isInd9: false,
  isInd10: false,
  dashboard: [],
  basicDatum: [],
  systemManage: [],
  courseCategory: [],
  lecturers: [],
  videos: [],
  audios: [],
  articles: [],
  previews: [],
  columns: [],
  datums: [],
  test: [],
  resource: [],
  social: [],
  activities: [],
  comment: [],
  mallInfo: [],
  productList: [],
  orderList: [],
  mallSetting: [],
  members: [],
  vipBenefit: [],
  partner: [],
  point: [],
  order: [],
  cashManage: [],
  companyIncome: [],
  userIncome: [],
  business: [],
  wxapp: []
}
let beforChangeDashboard = []
let beforChangeBasicDatum = []
let beforSystemManage = []
let beforCourseCategory = []
let beforLecturers = []
let beforMembers = []
let beforVipBenefit = []
let beforVideos = []
let beforAudios = []
let beforArticles = []
let beforPreviews = []
let beforColumns = []
let beforDatums = []
let beforTest = []
let beforResource = []
let beforSocial = []
let beforActivities = []
let beforComment = []
let beforMallInfo = []
let beforProductList = []
let beforOrderList = []
let beforMallSetting = []
let beforPartner = []
let beforPoint = []
let beforOrder = []
let beforCashManage = []
let beforCompanyIncome = []
let beforUserIncome = []
let beforBusiness = []
let beforWxapp = []
export default {
  props: {
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  created() {
    this.getEnableModel()
    this.postForm.adminId = this.$route.params.id
    if (this.postForm.adminId) {
      this.showPwd = false
      this.getPermissionDetail(this.postForm.adminId)
    }
  },
  data() {
    return {
      postForm: Object.assign({}, postForm),
      activeName: ['1'], // 权限展开的一栏
      rules,
      enableResourceModule: false, // 资源模块
      enablePoints: false, // 积分模块
      enableAgentLevels: false,
      isInd6: true,
      enableDatumModule: false, // 资料模块
      enableSocialGroup: false, // 社群模块
      enableExamModule: false, // 测评模块
      enableWxapp: false, // 小程序模块
      enableMallModule: false, // 商城模块
      enableColumnModule: false, // 专栏模块
      enableActivityModule: false, // 活动模块
      formLoading: false,
      btnLoading: false,
      showPwd: true,
      dashboard,
      basicDatum,
      systemManage,
      courseCategory,
      lecturers,
      resource,
      videos,
      audios,
      articles,
      previews,
      columns,
      datums,
      test,
      social,
      activities,
      comment,
      mallSetting,
      mallInfo,
      productList,
      orderList,
      point,
      partner,
      members,
      vipBenefit,
      order,
      cashManage,
      companyIncome,
      userIncome,
      business,
      wxapp
    }
  },
  methods: {
    getEnableModel() {
      const enableModule = enableModules()
      this.enableResourceModule = enableModule.enableResourceModule
      this.enablePoints = enableModule.enablePoints
      this.enableDatumModule = enableModule.enableDatumModule
      this.enableSocialGroup = enableModule.enableSocialGroup
      this.enableExamModule = enableModule.enableExamModule
      this.enableWxapp = enableModule.enableWxapp
      this.enableMallModule = enableModule.enableMallModule
      this.enableColumnModule = enableModule.enableColumnModule
      this.enableActivityModule = enableModule.enableActivityModule
      this.enableAgentLevels = enableModule.agentLevels
      if (this.enableAgentLevels || this.enablePoints) {
        this.isInd6 = true
      } else {
        this.isInd6 = false
      }
    },
    getPermissionDetail(id) {
      getPermissionDetail(id).then(res => {
        if (res.data.statusCode == 200) {
          this.postForm = res.data.data
          this.postForm.status = res.data.data.status.toString()
          this.showPwd = false
          beforChangeDashboard = res.data.data.dashboard
          beforChangeBasicDatum = res.data.data.basicDatum
          beforSystemManage = res.data.data.systemManage
          beforCourseCategory = res.data.data.courseCategory
          beforLecturers = res.data.data.lecturers
          beforMembers = res.data.data.members
          beforVipBenefit = res.data.data.vipBenefit
          beforVideos = res.data.data.videos
          beforAudios = res.data.data.audios
          beforArticles = res.data.data.articles
          beforPreviews = res.data.data.previews
          beforColumns = res.data.data.columns
          beforDatums = res.data.data.datums
          beforTest = res.data.data.test
          beforResource = res.data.data.resource
          beforSocial = res.data.data.social
          beforActivities = res.data.data.activities
          beforComment = res.data.data.comment
          beforMallInfo = res.data.data.mallInfo
          beforProductList = res.data.data.productList
          beforOrderList = res.data.data.orderList
          beforMallSetting = res.data.data.mallSetting
          beforPartner = res.data.data.partner
          beforPoint = res.data.data.point
          beforOrder = res.data.data.order
          beforCashManage = res.data.data.cashManage
          beforCompanyIncome = res.data.data.companyIncome
          beforUserIncome = res.data.data.userIncome
          beforBusiness = res.data.data.business
          beforWxapp = res.data.data.wxapp
        }
      }).catch(error => {
        console.log(error)
      })
    },
    handleChange(val) {
      // console.log(val)
    },
    handleCheckAllChange1(event) {
      if (event) {
        this.postForm.all1 = true
        this.postForm.dashboard = [-1, 1, 2]
      } else {
        this.postForm.all1 = false
        this.postForm.dashboard = []
      }
    },
    handleCheckAllChange2(event) {
      if (event) {
        this.postForm.all2 = true
        this.postForm.basicDatum = [-1, 1, 2]
        this.postForm.systemManage = [-1, 1, 2]
        this.postForm.courseCategory = [-1, 1, 2]
        this.postForm.lecturers = [-1, 1, 2]
      } else {
        this.postForm.all2 = false
        this.postForm.isInd2 = false
        this.postForm.basicDatum = []
        this.postForm.systemManage = []
        this.postForm.courseCategory = []
        this.postForm.lecturers = []
      }
    },
    handleCheckAllChange3(event) {
      if (event) {
        this.postForm.all3 = true
        this.postForm.videos = [-1, 1, 2]
        this.postForm.audios = [-1, 1, 2]
        this.postForm.articles = [-1, 1, 2]
        this.postForm.previews = [-1, 1, 2]
        if (this.enableColumnModule) {
          this.postForm.columns = [-1, 1, 2]
        } else {
          this.postForm.columns = []
        }
        if (this.enableDatumModule) {
          this.postForm.datums = [-1, 1, 2]
        } else {
          this.postForm.datums = []
        }
        if (this.enableExamModule) {
          this.postForm.test = [-1, 1, 2]
        } else {
          this.postForm.test = []
        }
        if (this.enableResourceModule) {
          this.postForm.resource = [-1, 1, 2]
        } else {
          this.postForm.resource = []
        }
      } else {
        this.postForm.all3 = false
        this.postForm.videos = []
        this.postForm.audios = []
        this.postForm.articles = []
        this.postForm.previews = []
        this.postForm.columns = []
        this.postForm.datums = []
        this.postForm.test = []
        this.postForm.resource = []
      }
    },
    handleCheckAllChange4(event) {
      if (event) {
        this.postForm.all4 = true
        this.postForm.social = [-1, 1, 2]
        if (this.enableSocialGroup) {
          this.postForm.social = [-1, 1, 2]
        } else {
          this.postForm.social = []
        }
        if (this.enableActivityModule) {
          this.postForm.activities = [-1, 1, 2]
        } else {
          this.postForm.activities = []
        }
        this.postForm.comment = [-1, 1, 2]
      } else {
        this.postForm.all4 = false
        this.postForm.social = []
        this.postForm.activities = []
        this.postForm.comment = []
      }
    },
    handleCheckAllChange5(event) {
      if (event) {
        this.postForm.all5 = true
        this.postForm.productList = [-1, 1, 2]
        this.postForm.mallInfo = [-1, 1, 2]
        this.postForm.orderList = [-1, 1, 2]
        this.postForm.mallSetting = [-1, 1, 2]
      } else {
        this.postForm.all5 = false
        this.postForm.isInd5 = false
        this.postForm.productList = []
        this.postForm.mallInfo = []
        this.postForm.orderList = []
        this.postForm.mallSetting = []
      }
    },
    handleCheckAllChange6(event) {
      if (event) {
        this.postForm.all6 = true
        if (this.enableAgentLevels) {
          this.postForm.partner = [-1, 1, 2]
        } else {
          this.postForm.partner = []
        }
        if (this.enablePoints) {
          this.postForm.point = [-1, 1, 2]
        } else {
          this.postForm.point = []
        }
      } else {
        this.postForm.all6 = false
        this.postForm.isInd5 = false
        this.postForm.partner = []
        this.postForm.point = []
      }
    },
    handleCheckAllChange7(event) {
      if (event) {
        this.postForm.all7 = true
        this.postForm.order = [-1, 1, 2]
      } else {
        this.postForm.all7 = false
        this.postForm.order = []
      }
    },
    handleCheckAllChange8(event) {
      if (event) {
        this.postForm.all8 = true
        this.postForm.cashManage = [-1, 1, 2]
        this.postForm.companyIncome = [-1, 1, 2]
        this.postForm.userIncome = [-1, 1, 2]
        this.postForm.business = [-1, 1, 2]
      } else {
        this.postForm.all8 = false
        this.postForm.isInd5 = false
        this.postForm.cashManage = []
        this.postForm.companyIncome = []
        this.postForm.userIncome = []
        this.postForm.business = []
      }
    },
    handleCheckAllChange9(event) {
      if (event) {
        this.postForm.all9 = true
        this.postForm.wxapp = [-1, 1, 2]
      } else {
        this.postForm.all9 = false
        this.postForm.wxapp = []
      }
    },
    handleCheckAllChange10(event) {
      if (event) {
        this.postForm.all10 = true
        this.postForm.members = [-1, 1, 2]
        this.postForm.vipBenefit = [-1, 1, 2]
      } else {
        this.postForm.all10 = false
        this.postForm.members = []
        this.postForm.vipBenefit = []
      }
    },
    dashboardFun(value) {
      /**
        1.[]选中第一个  -1 --------- [-1,1,2]
        2.[]选中第二个 1 -----------[1]
        3.[]选中第三个2 ------------[-1,1,2]
        4.[-1,1,2]选中第一个 [1,2] ---------[]
        5.[-1,1,2]选中第二个[-1,2]---------[]
        6.[-1,1,2]选中第三个[-1,1]---------[1]
        7.[1]选中第一个[-1,1] -------------[-1,1,2]
        8.[1]选中第二个[] -----------------[]
        9.[1]选中第三个[1,2] --------------[-1,1,2]
      */
      if (beforChangeDashboard.length == 0) {
        if (value.includes(1)) {
          this.postForm.dashboard = [1]
          this.postForm.isInd1 = true
        } else {
          this.postForm.dashboard = [-1, 1, 2]
          this.postForm.isInd1 = false
        }
      } else if (beforChangeDashboard.length == 1) {
        if (value.includes(1)) {
          this.postForm.dashboard = [-1, 1, 2]
          this.postForm.isInd1 = false
        } else {
          this.postForm.dashboard = []
          this.postForm.isInd1 = false
        }
      } else {
        if (value.includes(2)) {
          this.postForm.dashboard = []
          this.postForm.isInd1 = false
        } else {
          this.postForm.dashboard = [1]
          this.postForm.isInd1 = true
        }
      }
      if (this.postForm.dashboard.length == 0) {
        this.postForm.all1 = false
      } else {
        this.postForm.all1 = true
      }
      beforChangeDashboard = this.postForm.dashboard
    },
    shopManage() {
      if (this.postForm.basicDatum.length == 3 && this.postForm.systemManage.length == 3 && this.postForm.courseCategory.length == 3 && this.postForm.lecturers.length == 3) {
        this.postForm.isInd2 = false
      } else {
        this.postForm.isInd2 = true
      }
      if (this.postForm.basicDatum.length || this.postForm.systemManage.length || this.postForm.courseCategory.length || this.postForm.lecturers.length) {
        this.postForm.all2 = true
      } else {
        this.postForm.isInd2 = false
        this.postForm.all2 = false
      }
    },
    basicDatumFun(value) {
      if (beforChangeBasicDatum.length == 0) {
        if (value.includes(1)) {
          this.postForm.basicDatum = [1]
        } else {
          this.postForm.basicDatum = [-1, 1, 2]
        }
      } else if (beforChangeBasicDatum.length == 1) {
        if (value.includes(1)) {
          this.postForm.basicDatum = [-1, 1, 2]
        } else {
          this.postForm.basicDatum = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.basicDatum = []
        } else {
          this.postForm.basicDatum = [1]
        }
      }
      beforChangeBasicDatum = this.postForm.basicDatum
      this.shopManage()
    },
    systemManageFun(value) {
      if (beforSystemManage.length == 0) {
        if (value.includes(1)) {
          this.postForm.systemManage = [1]
        } else {
          this.postForm.systemManage = [-1, 1, 2]
        }
      } else if (beforSystemManage.length == 1) {
        if (value.includes(1)) {
          this.postForm.systemManage = [-1, 1, 2]
        } else {
          this.postForm.systemManage = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.systemManage = []
        } else {
          this.postForm.systemManage = [1]
        }
      }
      beforSystemManage = this.postForm.systemManage
      this.shopManage()
    },
    courseCategoryFun(value) {
      if (beforCourseCategory.length == 0) {
        if (value.includes(1)) {
          this.postForm.courseCategory = [1]
        } else {
          this.postForm.courseCategory = [-1, 1, 2]
        }
      } else if (beforCourseCategory.length == 1) {
        if (value.includes(1)) {
          this.postForm.courseCategory = [-1, 1, 2]
        } else {
          this.postForm.courseCategory = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.courseCategory = []
        } else {
          this.postForm.courseCategory = [1]
        }
      }
      beforCourseCategory = this.postForm.courseCategory
      this.shopManage()
    },
    lecturersFun(value) {
      if (beforLecturers.length == 0) {
        if (value.includes(1)) {
          this.postForm.lecturers = [1]
        } else {
          this.postForm.lecturers = [-1, 1, 2]
        }
      } else if (beforLecturers.length == 1) {
        if (value.includes(1)) {
          this.postForm.lecturers = [-1, 1, 2]
        } else {
          this.postForm.lecturers = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.lecturers = []
        } else {
          this.postForm.lecturers = [1]
        }
      }
      beforLecturers = this.postForm.lecturers
      this.shopManage()
    },
    knowledge() {
      if ((this.postForm.resource.length == 3 || !this.enableResourceModule) && (this.postForm.test.length == 3 || !this.enableExamModule) && (this.postForm.datums.length == 3 || !this.enableDatumModule) && this.postForm.videos.length == 3 && this.postForm
        .audios.length == 3 &&
        this.postForm.articles.length == 3 && this.postForm.previews.length == 3 && (this.postForm.columns.length == 3 || !this.enableColumnModule)) {
        this.postForm.isInd3 = false
      } else {
        this.postForm.isInd3 = true
      }
      if ((this.postForm.resource.length && this.enableResourceModule) || (this.postForm.test.length && this.enableExamModule) || (this.postForm.datums.length && this.enableDatumModule) || this.postForm.videos.length || this.postForm.audios.length ||
        this.postForm.articles.length ||
        this.postForm.previews.length || (this.postForm.columns.length && this.enableColumnModule)) {
        this.postForm.all3 = true
      } else {
        this.postForm.isInd3 = false
        this.postForm.all3 = false
      }
    },
    videosFun(value) {
      if (beforVideos.length == 0) {
        if (value.includes(1)) {
          this.postForm.videos = [1]
        } else {
          this.postForm.videos = [-1, 1, 2]
        }
      } else if (beforVideos.length == 1) {
        if (value.includes(1)) {
          this.postForm.videos = [-1, 1, 2]
        } else {
          this.postForm.videos = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.videos = []
        } else {
          this.postForm.videos = [1]
        }
      }
      beforVideos = this.postForm.videos
      this.knowledge()
    },
    audiosFun(value) {
      if (beforAudios.length == 0) {
        if (value.includes(1)) {
          this.postForm.audios = [1]
        } else {
          this.postForm.audios = [-1, 1, 2]
        }
      } else if (beforAudios.length == 1) {
        if (value.includes(1)) {
          this.postForm.audios = [-1, 1, 2]
        } else {
          this.postForm.audios = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.audios = []
        } else {
          this.postForm.audios = [1]
        }
      }
      beforAudios = this.postForm.audios
      this.knowledge()
    },
    articlesFun(value) {
      if (beforArticles.length == 0) {
        if (value.includes(1)) {
          this.postForm.articles = [1]
        } else {
          this.postForm.articles = [-1, 1, 2]
        }
      } else if (beforArticles.length == 1) {
        if (value.includes(1)) {
          this.postForm.articles = [-1, 1, 2]
        } else {
          this.postForm.articles = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.articles = []
        } else {
          this.postForm.articles = [1]
        }
      }
      beforArticles = this.postForm.articles
      this.knowledge()
    },
    previewsFun(value) {
      if (beforPreviews.length == 0) {
        if (value.includes(1)) {
          this.postForm.previews = [1]
        } else {
          this.postForm.previews = [-1, 1, 2]
        }
      } else if (beforPreviews.length == 1) {
        if (value.includes(1)) {
          this.postForm.previews = [-1, 1, 2]
        } else {
          this.postForm.previews = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.previews = []
        } else {
          this.postForm.previews = [1]
        }
      }
      beforPreviews = this.postForm.previews
      this.knowledge()
    },
    columnsFun(value) {
      if (beforColumns.length == 0) {
        if (value.includes(1)) {
          this.postForm.columns = [1]
        } else {
          this.postForm.columns = [-1, 1, 2]
        }
      } else if (beforColumns.length == 1) {
        if (value.includes(1)) {
          this.postForm.columns = [-1, 1, 2]
        } else {
          this.postForm.columns = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.columns = []
        } else {
          this.postForm.columns = [1]
        }
      }
      beforColumns = this.postForm.columns
      this.knowledge()
    },
    datumsFun(value) {
      if (beforDatums.length == 0) {
        if (value.includes(1)) {
          this.postForm.datums = [1]
        } else {
          this.postForm.datums = [-1, 1, 2]
        }
      } else if (beforDatums.length == 1) {
        if (value.includes(1)) {
          this.postForm.datums = [-1, 1, 2]
        } else {
          this.postForm.datums = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.datums = []
        } else {
          this.postForm.datums = [1]
        }
      }
      beforDatums = this.postForm.datums
      this.knowledge()
    },
    testFun(value) {
      if (beforTest.length == 0) {
        if (value.includes(1)) {
          this.postForm.test = [1]
        } else {
          this.postForm.test = [-1, 1, 2]
        }
      } else if (beforTest.length == 1) {
        if (value.includes(1)) {
          this.postForm.test = [-1, 1, 2]
        } else {
          this.postForm.test = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.test = []
        } else {
          this.postForm.test = [1]
        }
      }
      beforTest = this.postForm.test
      this.knowledge()
    },
    resourceFun(value) {
      if (beforResource.length == 0) {
        if (value.includes(1)) {
          this.postForm.resource = [1]
        } else {
          this.postForm.resource = [-1, 1, 2]
        }
      } else if (beforResource.length == 1) {
        if (value.includes(1)) {
          this.postForm.resource = [-1, 1, 2]
        } else {
          this.postForm.resource = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.resource = []
        } else {
          this.postForm.resource = [1]
        }
      }
      beforResource = this.postForm.resource
      this.knowledge()
    },

    interaction() {
      if ((this.postForm.social.length == 3 || !this.enableSocialGroup) && (this.postForm.activities.length == 3 || !this.enableActivityModule) && this.postForm.comment.length == 3) {
        this.postForm.isInd4 = false
      } else {
        this.postForm.isInd4 = true
      }
      if ((this.postForm.social.length && this.enableSocialGroup) || (this.postForm.activities.length && this.enableActivityModule) || this.postForm.comment.length) {
        this.postForm.all4 = true
      } else {
        this.postForm.isInd4 = false
        this.postForm.all4 = false
      }
    },
    socialFun(value) {
      if (beforSocial.length == 0) {
        if (value.includes(1)) {
          this.postForm.social = [1]
        } else {
          this.postForm.social = [-1, 1, 2]
        }
      } else if (beforSocial.length == 1) {
        if (value.includes(1)) {
          this.postForm.social = [-1, 1, 2]
        } else {
          this.postForm.social = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.social = []
        } else {
          this.postForm.social = [1]
        }
      }
      beforSocial = this.postForm.social
      this.interaction()
    },
    activitiesFun(value) {
      if (beforActivities.length == 0) {
        if (value.includes(1)) {
          this.postForm.activities = [1]
        } else {
          this.postForm.activities = [-1, 1, 2]
        }
      } else if (beforActivities.length == 1) {
        if (value.includes(1)) {
          this.postForm.activities = [-1, 1, 2]
        } else {
          this.postForm.activities = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.activities = []
        } else {
          this.postForm.activities = [1]
        }
      }
      beforActivities = this.postForm.activities
      this.interaction()
    },
    commentFun(value) {
      if (beforComment.length == 0) {
        if (value.includes(1)) {
          this.postForm.comment = [1]
        } else {
          this.postForm.comment = [-1, 1, 2]
        }
      } else if (beforComment.length == 1) {
        if (value.includes(1)) {
          this.postForm.comment = [-1, 1, 2]
        } else {
          this.postForm.comment = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.comment = []
        } else {
          this.postForm.comment = [1]
        }
      }
      beforComment = this.postForm.comment
      this.interaction()
    },
    mall() {
      if (this.postForm.mallInfo.length == 3 && this.postForm.productList.length == 3 && this.postForm.orderList.length == 3 && this.postForm.mallSetting.length == 3) {
        this.postForm.isInd5 = false
      } else {
        this.postForm.isInd5 = true
      }
      if (this.postForm.mallInfo.length || this.postForm.productList.length || this.postForm.orderList.length || this.postForm.mallSetting.length) {
        this.postForm.all5 = true
      } else {
        this.postForm.isInd5 = false
        this.postForm.all5 = false
      }
    },
    mallInfoFun(value) {
      if (beforMallInfo.length == 0) {
        if (value.includes(1)) {
          this.postForm.mallInfo = [1]
        } else {
          this.postForm.mallInfo = [-1, 1, 2]
        }
      } else if (beforMallInfo.length == 1) {
        if (value.includes(1)) {
          this.postForm.mallInfo = [-1, 1, 2]
        } else {
          this.postForm.mallInfo = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.mallInfo = []
        } else {
          this.postForm.mallInfo = [1]
        }
      }
      beforMallInfo = this.postForm.mallInfo
      this.mall()
    },
    productListFun(value) {
      if (beforProductList.length == 0) {
        if (value.includes(1)) {
          this.postForm.productList = [1]
        } else {
          this.postForm.productList = [-1, 1, 2]
        }
      } else if (beforProductList.length == 1) {
        if (value.includes(1)) {
          this.postForm.productList = [-1, 1, 2]
        } else {
          this.postForm.productList = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.productList = []
        } else {
          this.postForm.productList = [1]
        }
      }
      beforProductList = this.postForm.productList
      this.mall()
    },
    orderListFun(value) {
      if (beforOrderList.length == 0) {
        if (value.includes(1)) {
          this.postForm.orderList = [1]
        } else {
          this.postForm.orderList = [-1, 1, 2]
        }
      } else if (beforOrderList.length == 1) {
        if (value.includes(1)) {
          this.postForm.orderList = [-1, 1, 2]
        } else {
          this.postForm.orderList = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.orderList = []
        } else {
          this.postForm.orderList = [1]
        }
      }
      beforOrderList = this.postForm.orderList
      this.mall()
    },
    mallSettingFun(value) {
      if (beforMallSetting.length == 0) {
        if (value.includes(1)) {
          this.postForm.mallSetting = [1]
        } else {
          this.postForm.mallSetting = [-1, 1, 2]
        }
      } else if (beforMallSetting.length == 1) {
        if (value.includes(1)) {
          this.postForm.mallSetting = [-1, 1, 2]
        } else {
          this.postForm.mallSetting = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.mallSetting = []
        } else {
          this.postForm.mallSetting = [1]
        }
      }
      beforMallSetting = this.postForm.mallSetting
      this.mall()
    },
    member() {
      if (this.postForm.members.length == 3 && this.postForm.vipBenefit.length == 3) {
        this.postForm.isInd10 = false
      } else {
        this.postForm.isInd10 = true
      }
      if (this.postForm.members.length || this.postForm.vipBenefit.length) {
        this.postForm.all10 = true
      } else {
        this.postForm.isInd10 = false
        this.postForm.all10 = false
      }
    },
    membersFun(value) {
      if (beforMembers.length == 0) {
        if (value.includes(1)) {
          this.postForm.members = [1]
        } else {
          this.postForm.members = [-1, 1, 2]
        }
      } else if (beforMembers.length == 1) {
        if (value.includes(1)) {
          this.postForm.members = [-1, 1, 2]
        } else {
          this.postForm.members = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.members = []
        } else {
          this.postForm.members = [1]
        }
      }
      beforMembers = this.postForm.members
      this.member()
    },
    vipBenefitFun(value) {
      if (beforVipBenefit.length == 0) {
        if (value.includes(1)) {
          this.postForm.vipBenefit = [1]
        } else {
          this.postForm.vipBenefit = [-1, 1, 2]
        }
      } else if (beforVipBenefit.length == 1) {
        if (value.includes(1)) {
          this.postForm.vipBenefit = [-1, 1, 2]
        } else {
          this.postForm.vipBenefit = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.vipBenefit = []
        } else {
          this.postForm.vipBenefit = [1]
        }
      }
      beforVipBenefit = this.postForm.vipBenefit
      this.member()
    },
    marketing() {
      if ((this.postForm.partner.length == 3 || !this.enableAgentLevels) && (this.postForm.point.length == 3 || !this.enablePoints)) {
        this.postForm.isInd6 = false
      } else {
        this.postForm.isInd6 = true
      }
      if ((this.postForm.partner.length && this.enableAgentLevels) || (this.postForm.point.length && this.enablePoints)) {
        this.postForm.all6 = true
      } else {
        this.postForm.isInd6 = false
        this.postForm.all6 = false
      }
    },
    partnerFun(value) {
      if (beforPartner.length == 0) {
        if (value.includes(1)) {
          this.postForm.partner = [1]
        } else {
          this.postForm.partner = [-1, 1, 2]
        }
      } else if (beforPartner.length == 1) {
        if (value.includes(1)) {
          this.postForm.partner = [-1, 1, 2]
        } else {
          this.postForm.partner = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.partner = []
        } else {
          this.postForm.partner = [1]
        }
      }
      beforPartner = this.postForm.partner
      this.marketing()
    },
    pointFun(value) {
      if (beforPoint.length == 0) {
        if (value.includes(1)) {
          this.postForm.point = [1]
        } else {
          this.postForm.point = [-1, 1, 2]
        }
      } else if (beforPoint.length == 1) {
        if (value.includes(1)) {
          this.postForm.point = [-1, 1, 2]
        } else {
          this.postForm.point = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.point = []
        } else {
          this.postForm.point = [1]
        }
      }
      beforPoint = this.postForm.point
      this.marketing()
    },
    orderFun(value) {
      if (beforOrder.length == 0) {
        if (value.includes(1)) {
          this.postForm.order = [1]
          this.postForm.isInd7 = true
        } else {
          this.postForm.order = [-1, 1, 2]
          this.postForm.isInd7 = false
        }
      } else if (beforOrder.length == 1) {
        if (value.includes(1)) {
          this.postForm.order = [-1, 1, 2]
          this.postForm.isInd7 = false
        } else {
          this.postForm.order = []
          this.postForm.isInd7 = false
        }
      } else {
        if (value.includes(2)) {
          this.postForm.order = []
          this.postForm.isInd7 = false
        } else {
          this.postForm.order = [1]
          this.postForm.isInd7 = true
        }
      }
      beforOrder = this.postForm.order

      if (this.postForm.order.length == 0) {
        this.postForm.all7 = false
      } else {
        this.postForm.all7 = true
      }
    },
    financed() {
      if (this.postForm.cashManage.length == 3 && this.postForm.companyIncome.length == 3 && this.postForm.userIncome.length == 3 && this.postForm.business.length == 3) {
        this.postForm.isInd8 = false
      } else {
        this.postForm.isInd8 = true
      }
      if (this.postForm.cashManage.length || this.postForm.companyIncome.length || this.postForm.userIncome.length || this.postForm.business.length) {
        this.postForm.all8 = true
      } else {
        this.postForm.isInd8 = false
        this.postForm.all8 = false
      }
    },
    cashManageFun(value) {
      if (beforCashManage.length == 0) {
        if (value.includes(1)) {
          this.postForm.cashManage = [1]
        } else {
          this.postForm.cashManage = [-1, 1, 2]
        }
      } else if (beforCashManage.length == 1) {
        if (value.includes(1)) {
          this.postForm.cashManage = [-1, 1, 2]
        } else {
          this.postForm.cashManage = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.cashManage = []
        } else {
          this.postForm.cashManage = [1]
        }
      }
      beforCashManage = this.postForm.cashManage
      this.financed()
    },
    companyIncomeFun(value) {
      if (beforCompanyIncome.length == 0) {
        if (value.includes(1)) {
          this.postForm.companyIncome = [1]
        } else {
          this.postForm.companyIncome = [-1, 1, 2]
        }
      } else if (beforCompanyIncome.length == 1) {
        if (value.includes(1)) {
          this.postForm.companyIncome = [-1, 1, 2]
        } else {
          this.postForm.companyIncome = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.companyIncome = []
        } else {
          this.postForm.companyIncome = [1]
        }
      }
      beforCompanyIncome = this.postForm.companyIncome
      this.financed()
    },
    userIncomeFun(value) {
      if (beforUserIncome.length == 0) {
        if (value.includes(1)) {
          this.postForm.userIncome = [1]
        } else {
          this.postForm.userIncome = [-1, 1, 2]
        }
      } else if (beforUserIncome.length == 1) {
        if (value.includes(1)) {
          this.postForm.userIncome = [-1, 1, 2]
        } else {
          this.postForm.userIncome = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.userIncome = []
        } else {
          this.postForm.userIncome = [1]
        }
      }
      beforUserIncome = this.postForm.userIncome
      this.financed()
    },
    businessFun(value) {
      if (beforBusiness.length == 0) {
        if (value.includes(1)) {
          this.postForm.business = [1]
        } else {
          this.postForm.business = [-1, 1, 2]
        }
      } else if (beforBusiness.length == 1) {
        if (value.includes(1)) {
          this.postForm.business = [-1, 1, 2]
        } else {
          this.postForm.business = []
        }
      } else {
        if (value.includes(2)) {
          this.postForm.business = []
        } else {
          this.postForm.business = [1]
        }
      }
      beforBusiness = this.postForm.business
      this.financed()
    },
    wxappFun(value) {
      if (beforWxapp.length == 0) {
        if (value.includes(1)) {
          this.postForm.wxapp = [1]
          this.postForm.isInd9 = true
        } else {
          this.postForm.wxapp = [-1, 1, 2]
          this.postForm.isInd9 = false
        }
      } else if (beforWxapp.length == 1) {
        if (value.includes(1)) {
          this.postForm.wxapp = [-1, 1, 2]
        } else {
          this.postForm.wxapp = []
          this.postForm.isInd9 = false
        }
      } else {
        if (value.includes(2)) {
          this.postForm.wxapp = []
          this.postForm.isInd9 = true
        } else {
          this.postForm.wxapp = [1]
          this.postForm.isInd9 = false
        }
      }
      beforWxapp = this.postForm.wxapp
      if (this.postForm.wxapp.length == 0) {
        this.postForm.all9 = false
      } else {
        this.postForm.all9 = true
      }
    },
    handleCheckedCitiesChange1(value) {
      const checkedCount = value.length
      this.postForm.checkAll = checkedCount === this.dashboard.length
      this.postForm.isInd7 = checkedCount > 0 && checkedCount < this.dashboard.length
    },
    close() {
      this.$store.dispatch('delVisitedViews', this.$route).then((views) => {
        const latestView = views.slice(-1)[0]
        if (latestView) {
          this.$router.push({ path: `/shopManage/accountMember` })
        } else {
          this.$router.push('/')
        }
      })
    },
    submitForm() {
      if (this.btnLoading) {
        return
      }
      this.btnLoading = true
      this.$refs.postForm.validate((valid) => {
        if (valid) {
          savePermission(this.postForm).then(res => {
            if (res.data.statusCode == 200) {
              this.$message({
                message: '保存成功！',
                type: 'success'
              })
              this.close()
            } else {
              this.$message({
                message: res.data.msg,
                type: 'error'
              })
            }
            this.btnLoading = false
          }).catch(error => {
            console.log(error)
            this.btnLoading = false
          })
        }
      })
    } // 提交表单
  }
}
</script>
<style scoped>
.m-l-30 {
  margin-left: 30px;
}
</style>
